package com.fsnbigdata.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.springlets.format.EntityFormat;
import org.hibernate.validator.constraints.Length;
import org.springframework.roo.addon.javabean.annotations.RooEquals;
import org.springframework.roo.addon.javabean.annotations.RooJavaBean;
import org.springframework.roo.addon.javabean.annotations.RooToString;
import org.springframework.roo.addon.jpa.annotations.entity.RooJpaEntity;

import javax.persistence.*;
import java.util.Objects;

/**
 * Created by zq on 2019/4/19.
 */
@RooJavaBean
@RooToString
@RooJpaEntity(entityFormatExpression = "#{name}")
@RooEquals(isJpaEntity = true)
@Entity
@EntityFormat("#{name}")
public class AnimalConservationImage {

        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;


        @Version
        private Integer version;

        @JsonIgnore
        @ManyToOne(fetch = FetchType.EAGER)
        @EntityFormat
        private AnimalConservation animalConservation;


        @Length(min = 0, max = 255,message = "code长度必须0-255之间")
        private String code;



        @Length(min = 0, max = 255,message = "description长度必须0-255之间")
        private String description;

        /**
         * TODO Auto-generated attribute documentation
         *
         */
        @Length(min = 0, max = 255,message = "location长度必须0-255之间")
        private String location;


        @Length(min = 0, max = 255,message = "author长度必须0-255之间")
        private String author;


        @Length(min = 0, max = 255,message = "url长度必须0-255之间")
        private String url;


        @Length(min = 0, max = 255,message = "createDate长度必须0-255之间")
        private String createDate;


        public static final String ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";


        public static final String ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";


        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            // instanceof is false if the instance is null
            if (!(obj instanceof com.fsnbigdata.domain.AnimalConservationImage)) {
                return false;
            }
            return getId() != null && Objects.equals(getId(), ((com.fsnbigdata.domain.AnimalConservationImage) obj).getId());
        }


        public int hashCode() {
            return 31;
        }


        public Long getId() {
            return this.id;
        }


        public void setId(Long id) {
            this.id = id;
        }


        public Integer getVersion() {
            return this.version;
        }


        public void setVersion(Integer version) {
            this.version = version;
        }


        public AnimalConservation getAnimalConservation() {
           return animalConservation;
        }

         public void setAnimalConservation(AnimalConservation animalConservation) {
            this.animalConservation = animalConservation;
        }

        public String getCode() {
            return this.code;
        }


        public void setCode(String code) {
            this.code = code;
        }


        public String getDescription() {
            return this.description;
        }

        public void setDescription(String description) {
            this.description = description;
        }


        public String getLocation() {
            return this.location;
        }


        public void setLocation(String location) {
            this.location = location;
        }


        public String getAuthor() {
            return this.author;
        }


        public void setAuthor(String author) {
            this.author = author;
        }


        public String getUrl() {
            return this.url;
        }

        public void setUrl(String url) {
            this.url = url;
        }


        public String getCreateDate() {
            return this.createDate;
        }


        public void setCreateDate(String createDate) {
            this.createDate = createDate;
        }

    public String toString() {
        return "AnimalConservationLocation {" + "id='" + id + '\'' +
                ", version='" + version + '\'' +
                ", code='" + code + '\'' +
                ", description='" + description + '\'' +
                ", location='" + location + '\'' +
                ", author='" + author + '\'' +
                ", url='" + url + '\'' +
                ", createDate='" + createDate + '\'' +
                ", ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE + '\'' +
                ", ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE + '\'' +
                "}" + super.toString();
    }
}
